home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Unix / netinet⁄in.h < prev    next >
Encoding:
Text File  |  1987-08-12  |  2.8 KB  |  130 lines  |  [TEXT/MPS ]

  1.  
  2. #ifndef  __NETINETIN__
  3. #define  __NETINETIN__
  4.  
  5.  
  6.  
  7. /*
  8.  * Protocols
  9.  */
  10. #define    IPPROTO_ICMP        1        /* control message protocol */
  11. #define    IPPROTO_GGP            2        /* gateway^2 (deprecated) */
  12. #define    IPPROTO_TCP            6        /* tcp */
  13. #define    IPPROTO_PUP            12        /* pup */
  14. #define    IPPROTO_UDP            17        /* user datagram protocol */
  15. #define    IPPROTO_ND            77        /* UNOFFICIAL net disk proto */
  16.  
  17. #define    IPPROTO_RAW            255        /* raw IP packet */
  18. #define    IPPROTO_MAX            256
  19.  
  20. /*
  21.  * Port/socket numbers: network standard functions
  22.  */
  23. #define    IPPORT_ECHO            7
  24. #define    IPPORT_DISCARD        9
  25. #define    IPPORT_SYSTAT        11
  26. #define    IPPORT_DAYTIME        13
  27. #define    IPPORT_NETSTAT        15
  28. #define    IPPORT_FTP            21
  29. #define    IPPORT_TELNET        23
  30. #define    IPPORT_SMTP            25
  31. #define    IPPORT_TIMESERVER    37
  32. #define    IPPORT_NAMESERVER    42
  33. #define    IPPORT_WHOIS        43
  34. #define    IPPORT_MTP            57
  35.  
  36. /*
  37.  * Port/socket numbers: host specific functions
  38.  */
  39. #define    IPPORT_TFTP            69
  40. #define    IPPORT_RJE            77
  41. #define    IPPORT_FINGER        79
  42. #define    IPPORT_TTYLINK        87
  43. #define    IPPORT_SUPDUP        95
  44.  
  45. /*
  46.  * UNIX TCP sockets
  47.  */
  48. #define    IPPORT_EXECSERVER    512
  49. #define    IPPORT_LOGINSERVER    513
  50. #define    IPPORT_CMDSERVER    514
  51. #define    IPPORT_EFSSERVER    520
  52.  
  53. /*
  54.  * UNIX UDP sockets
  55.  */
  56. #define    IPPORT_BIFFUDP        512
  57. #define    IPPORT_WHOSERVER    513
  58. #define    IPPORT_ROUTESERVER    520    /* 520+1 also used */
  59.  
  60. /*
  61.  * Ports < IPPORT_RESERVED are reserved for
  62.  * privileged processes (e.g. root).
  63.  */
  64. #define    IPPORT_RESERVED        1024
  65.  
  66. /*
  67.  * Link numbers
  68.  */
  69. #define    IMPLINK_IP            155
  70. #define    IMPLINK_LOWEXPER    156
  71. #define    IMPLINK_HIGHEXPER    158
  72.  
  73. /*
  74.  * Internet address (old style... should be updated)
  75.  */
  76. struct in_addr {
  77.     union {
  78.         struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  79.         struct { u_short s_w1,s_w2; } S_un_w;
  80.         u_long S_addr;
  81.     } S_un;
  82. #define    s_addr    S_un.S_addr    /* can be used for most tcp & ip code */
  83. #define    s_host    S_un.S_un_b.s_b2    /* host on imp */
  84. #define    s_net    S_un.S_un_b.s_b1    /* network */
  85. #define    s_imp    S_un.S_un_w.s_w2    /* imp */
  86. #define    s_impno    S_un.S_un_b.s_b4    /* imp # */
  87. #define    s_lh    S_un.S_un_b.s_b3    /* logical host */
  88. };
  89.  
  90. /*
  91.  * Definitions of bits in internet address integers.
  92.  */
  93. #define    IN_CLASSA(i)        ((((long)(i))&0x80000000)==0)
  94. #define    IN_CLASSA_NET        0xff000000
  95. #define    IN_CLASSA_NSHIFT    24
  96. #define    IN_CLASSA_HOST        0x00ffffff
  97.  
  98. #define    IN_CLASSB(i)        ((((long)(i))&0xc0000000)==0x80000000)
  99. #define    IN_CLASSB_NET        0xffff0000
  100. #define    IN_CLASSB_NSHIFT    16
  101. #define    IN_CLASSB_HOST        0x0000ffff
  102.  
  103. #define    IN_CLASSC(i)        ((((long)(i))&0xc0000000)==0xc0000000)
  104. #define    IN_CLASSC_NET        0xffffff00
  105. #define    IN_CLASSC_NSHIFT    8
  106. #define    IN_CLASSC_HOST        0x000000ff
  107.  
  108. #define    INADDR_ANY            0x00000000
  109.  
  110.  
  111. #define ntohl(x) (x)
  112. #define ntohs(x) (x)
  113. #define htonl(x) (x)
  114. #define htons(x) (x)
  115.  
  116.  
  117.  
  118. /*
  119.  * Socket address, internet style.
  120.  */
  121. typedef  struct  sockaddr_in {
  122.     short                sin_family;
  123.     u_short                sin_port;
  124.     struct    in_addr        sin_addr;
  125.     char                sin_zero[8];
  126.     };
  127.  
  128.  
  129.  
  130. #endif